#ifndef __BSP_MC_ADC_H
#define __BSP_MC_ADC_H

#ifdef __cplusplus
extern "C" {
#endif
	
#include "bsp_mc_type.h"
	
#define	CURRENT_ADC_CLK         RCC_APB2Periph_ADC1
	
#define	CURRENT_ADC_GPIO        GPIOB
#define	CURRENT_ADC_GPIO2       GPIOA

#define	CURRENT_ADC_GPIO_CLK    RCC_AHB1Periph_GPIOB
#define	CURRENT_ADC_GPIO2_CLK   RCC_AHB1Periph_GPIOA
#define CURRENT_ADC_IRQn     		ADC_IRQn
	
#define PHASE_A_ADC_CHANNEL     ADC_Channel_8
#define PHASE_A_GPIO_PORT       GPIOB
#define PHASE_A_GPIO_PIN        GPIO_Pin_0
		
#define PHASE_B_ADC_CHANNEL     ADC_Channel_9
#define PHASE_B_GPIO_PORT       GPIOB
#define PHASE_B_GPIO_PIN        GPIO_Pin_1
		
#define PHASE_C_ADC_CHANNEL     ADC_Channel_6
#define PHASE_C_GPIO_PORT       GPIOA
#define PHASE_C_GPIO_PIN        GPIO_Pin_6

#define PHASE_A_MSK       (u32)((u32)(PHASE_A_ADC_CHANNEL) << 15)
#define PHASE_B_MSK       (u32)((u32)(PHASE_B_ADC_CHANNEL) << 15)
#define PHASE_C_MSK       (u32)((u32)(PHASE_C_ADC_CHANNEL) << 15)
	
#define ADC_INJECTED_RANK_1    0x00000001U
#define ADC_INJECTED_RANK_2    0x00000002U
#define ADC_INJECTED_RANK_3    0x00000003U
#define ADC_INJECTED_RANK_4    0x00000004U

extern u16 hPhaseAOffset;
extern u16 hPhaseBOffset;
extern u16 hPhaseCOffset;


extern float rpm_fb;
extern s16 eleangle_fb;

void Motor_ADC_GPIO_Init(void);
void Motor_ADC_Mode_Init(void);
void Motor_ADC_Init(void);
void SVPWM_3ShuntCurrentReadingCalibration(void);
void SVPWM_InjectedConvConfig(void);

	
#ifdef __cplusplus
}
#endif

#endif


